home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / MPW IIGS Interfaces / PIIGSIncludes / Controls.p < prev    next >
Encoding:
Text File  |  1990-08-01  |  14.3 KB  |  426 lines  |  [TEXT/MPS ]

  1. {********************************************
  2. ; File: Controls.p
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc. 1986-90
  6. ; All Rights Reserved
  7. ;
  8. ********************************************}
  9.  
  10. UNIT CONTROLS;
  11.  
  12. INTERFACE
  13.  
  14. USES TYPES,QUICKDRAW,EVENTS;
  15.  
  16. CONST
  17. { Axis Parameters }
  18. noConstraint = $0000;  { No constraint on movement. }
  19. hAxisOnly = $0001;  { Horizontal axis only. }
  20. vAxisOnly = $0002;  { Vertical axis only. }
  21.  
  22. { CtlFlag }
  23. simpRound = $0000;  { Simple button flag }
  24. upFlag = $0001;  { Scroll bar flag.  }
  25. boldButton = $0001;  { Bold round cornered outlined button. }
  26. simpBRound = $0001;  { Simple button flag }
  27. downFlag = $0002;  { Scroll bar flag. }
  28. simpSquare = $0002;  { Simple button flag }
  29. simpDropSquare = $0003;  { Simple button flag }
  30. leftFlag = $0004;  { Scroll bar flag. }
  31. rightFlag = $0008;  { Scroll bar flag. }
  32. dirScroll = $0010;  { Scroll bar flag. }
  33. horScroll = $0010;  { Scroll bar flag. }
  34. family = $007F;  { Mask for radio button family number }
  35. ctlInVis = $0080;  { invisible mask for any type of control  }
  36. fCallWindowMgr = $0001;  { Control Template flag value }
  37. fSubstituteText = $0002;
  38. fSubTextType = $0001;
  39. inListBox = $88;
  40.  
  41. { CtlProc Codes }
  42. simpleProc = $00000000;
  43. checkProc = $02000000;
  44. radioProc = $04000000;
  45. scrollProc = $06000000;
  46. growProc = $08000000;
  47.  
  48. { DefProc Commands }
  49. drawCtl = $0000;  { Draw control command. }
  50. calcCRect = $0001;  { Compute drag RECT command. }
  51. testCtl = $0002;  { Hit test command. }
  52. initCtl = $0003;  { Initialize command. }
  53. dispCtl = $0004;  { Dispose command. }
  54. posCtl = $0005;  { Move indicator command. }
  55. thumbCtl = $0006;  { Compute drag parameters command. }
  56. dragCtl = $0007;  { Drag command. }
  57. autoTrack = $0008;  { Action command. }
  58. newValue = $0009;  { Set new value command. }
  59. setParams = $000A;  { Set new parameters command. }
  60. moveCtl = $000B;  { Move command. }
  61. recSize = $000C;  { Return record size command. }
  62. ctlHandleEvent = $000D;  { Handle a keystroke or menu selection }
  63. ctlChangeTarget = $000E;  { Issued when control's target status has changed }
  64. ctlChangeBounds = $000F;  { Issued when control's boundary rectangle has changed }
  65. ctlWindChangeSize = $0010;  { Window has been grown or zoomed }
  66. ctlHandleTab = $0011;  { Control has been tabbed to }
  67. ctlNotifyMultiPart = $0012;  { A multipart control has been hidden, drawn or shown }
  68. ctlWinStateChange = $0013;  { Window state has changed }
  69.  
  70. { hiliteState Codes }
  71. noHilite = $0000;  { Param to HiliteControl }
  72. inactiveHilite = $00FF;  { Param to HiliteControl }
  73.  
  74. { PartCode Numbers }
  75. noPart = $0000;
  76. simpleButton = $0002;
  77. checkBox = $0003;
  78. radioButton = $0004;
  79. upArrow = $0005;
  80. downArrow = $0006;
  81. pageUp = $0007;
  82. pageDown = $0008;
  83. growBox = $000A;
  84. thumb = $0081;
  85.  
  86. { moreFlags Codes }
  87. fCtlTarget = $8000;  { is current target of typing commands }
  88. fCtlCanBeTarget = $4000;  { can be made the target control }
  89. fCtlWantEvent = $2000;  { control can be called view SendEventToCtl }
  90. fCtlWantsEvent = $2000;  { control can be called view SendEventToCtl }
  91. fCtlWantEvents = $2000;  { control can be called view SendEventToCtl }
  92. fCtlWantsEvents = $2000;  { control can be called view SendEventToCtl }
  93. fCtlProcRefNotPtr = $1000;  { set = ID of defproc, clear = pointer to defproc }
  94. fCtlTellAboutSize = $0800;  { set if ctl needs notification when size of owning window changes }
  95. fCtlIsMultiPart = $0400;  { set if ctl needs notification to be hidden }
  96. fMenuDefIsText = $0004;
  97. colorDescriptor = $000C;  { indicates type of reference in colorRef }
  98. styleDescriptor = $0003;  { indicates type of reference in styleRef }
  99.  
  100. { Ctl Verbs }
  101. titleIsPtr = $00;
  102. titleIsHandle = $01;
  103. titleIsResource = $02;
  104. colorTableIsPtr = $00;
  105. colorTableIsHandle = $04;
  106. colorTableIsResource = $08;
  107. ctlHideCtl = $12;
  108.  
  109. { InputVerb Codes }
  110. singlePtr = $0000;
  111. singleHandle = $0001;
  112. singleResource = $0002;
  113. ptrToPtr = $0003;
  114. ptrToHandle = $0004;
  115. ptrToResource = $0005;
  116. handleToPtr = $0006;
  117. handleToHandle = $0007;
  118. handleToResource = $0008;
  119. resourceToResource = $0009;
  120.  
  121. { ProcRefs }
  122. simpleButtonControl = $80000000;
  123. checkControl = $82000000;
  124. radioControl = $84000000;
  125. scrollBarControl = $86000000;
  126. growControl = $88000000;
  127. statTextControl = $81000000;
  128. editLineControl = $83000000;
  129. editTextControl = $85000000;
  130. popUpControl = $87000000;
  131. listControl = $89000000;
  132. iconButtonControl = $07FF0001;
  133. pictureControl = $8D000000;
  134.  
  135. { Error Codes }
  136. wmNotStartedUp = $1001;  { Window manager was not initialized }
  137. cmNotInitialized = $1002;  { Control manager was not initialized }
  138. noCtlInList = $1003;  { Control not in window list }
  139. noCtlError = $1004;  { no controls in window }
  140. noSuperCtlError = $1005;  { no super controls in window }
  141. noCtlTargetError = $1006;  { no target super control }
  142. notSuperCtlError = $1007;  { action can only be done on super control }
  143. canNotBeTargetError = $1008;  { conrol cannot be made target }
  144. noSuchIDError = $1009;  { specified ID cannot be found }
  145. tooFewParmsError = $100A;  { not enough params specified }
  146. noCtlToBeTargetError = $100B;  { NextCtl call, no ctl could be target }
  147. noFrontWindowError = $100C;  { there is no front window }
  148.  
  149. { displayMode flags }
  150. selectedIcon = $0001;
  151. openIcon = $0002;
  152. offline = $0004;
  153.  
  154. { listType values }
  155. fListString = $0001;
  156. fListSelect = $0002;
  157. fListScrollBar = $0004;
  158.  
  159. { PopUp control flag values }
  160. fRightJustifyResult = $0001;
  161. fRightJustifyTitle = $0002;
  162. fInWindowOnly = $0004;
  163. fDontDrawResult = $0008;
  164. fDontDrawTitle = $0010;
  165. fDontHiliteTitle = $0020;
  166. fType2PopUp = $0040;
  167.  
  168. TYPE
  169. {$IFC UNDEFINED WindowPtr }
  170. WindowPtr = GrafPortPtr ;
  171. {$SETC WindowPtr := 0 }
  172. {$ENDC}
  173.  
  174.  
  175. BarColorsHndl = ^BarColorsPtr;
  176. BarColorsPtr = ^BarColors;
  177. BarColors = RECORD
  178.     barOutline : Integer; { color for outlining bar, arrows, and thumb }
  179.     barNorArrow : Integer; { color of arrows when not highlighted }
  180.     barSelArrow : Integer; { color of arrows when highlighted }
  181.     barArrowBack : Integer; { color of arrow box's background }
  182.     barNorThumb : Integer; { color of thumb's background when not highlighted }
  183.     barSelThumb : Integer; { color of thumb's background when highlighted }
  184.     barPageRgn : Integer; { color and pattern page region: high byte - 1= dither, 0 = solid }
  185.     barInactive : Integer; { color of scroll bar's interior when inactive }
  186. END;
  187.  
  188. BoxColorsHndl = ^BoxColorsPtr;
  189. BoxColorsPtr = ^BoxColors;
  190. BoxColors = RECORD
  191.     boxReserved : Integer; { reserved }
  192.     boxNor : Integer; { color of box when not checked }
  193.     boxSel : Integer; { color of box when checked }
  194.     boxTitle : Integer; { color of check box's title }
  195. END;
  196.  
  197. BttnColorsHndl = ^BttnColorsPtr;
  198. BttnColorsPtr = ^BttnColors;
  199. BttnColors = RECORD
  200.     bttnOutline : Integer; { color of outline }
  201.     bttnNorBack : Integer; { color of background when not selected }
  202.     bttnSelBack : Integer; { color of background when selected }
  203.     bttnNorText : Integer; { color of title's text when not selected }
  204.     bttnSelText : Integer; { color of title's text when selected }
  205. END;
  206.  
  207. CtlRecHndlPtr = ^CtlRecHndl;
  208. CtlRecHndl = ^CtlRecPtr;
  209. CtlRecPtr = ^CtlRec;
  210. CtlRec = PACKED RECORD
  211.     ctlNext : CtlRecHndl; { Handle of next control. }
  212.     ctlOwner : WindowPtr; { Pointer to control's window. }
  213.     ctlRect : Rect; { Enclosing rectangle. }
  214.     ctlFlag : Byte; { Bit flags. }
  215.     ctlHilite : Byte; { Highlighted part. }
  216.     ctlValue : Integer; { Control's value. }
  217.     ctlProc : LongProcPtr; { Control's definition procedure. }
  218.     ctlAction : LongProcPtr; { Control's action procedure. }
  219.     ctlData : Longint; { Reserved for CtrlProc's use. }
  220.     ctlRefCon : Longint; { Reserved for application's use. }
  221.     ctlColor : Ptr; { Pointer to appropriate color table. }
  222.     ctlReserved : PACKED ARRAY[1..16] OF Byte; { Reserved for future expansion }
  223.     ctlID : Longint;
  224.     ctlMoreFlags : Integer;
  225.     ctlVersion : Integer;
  226. END;
  227.  
  228. LimitBlkHndl = ^LimitBlkPtr;
  229. LimitBlkPtr = ^LimitBlk;
  230. LimitBlk = RECORD
  231.     boundRect : Rect; { Drag bounds. }
  232.     slopRect : Rect; { Cursor bounds. }
  233.     axisParam : Integer; { Movement constrains. }
  234.     dragPatt : Ptr; { Pointer to 32 byte Pattern for drag outline. }
  235. END;
  236.  
  237. RadioColorsHndl = ^RadioColorsPtr;
  238. RadioColorsPtr = ^RadioColors;
  239. RadioColors = RECORD
  240.     radReserved : Integer; { reserved }
  241.     radNor : Integer; { color of radio button when off }
  242.     radSel : Integer; { color of radio button when on }
  243.     radTitle : Integer; { color of radio button's title text }
  244. END;
  245.  
  246. KeystrokeRec = PACKED RECORD
  247.     key1 : Byte;
  248.     key2 : Byte;
  249.     keyModifiers : Integer;
  250.     keyCareBits : Integer;
  251. END;
  252.  
  253. ControlTemplate = RECORD
  254.     pCount : Integer;
  255.     ID : Longint;
  256.     rect : Rect;
  257.     procRef : Longint;
  258.     flag : Integer;
  259.     moreFlags : Integer;
  260.     refCon : Longint;
  261. END;
  262.  
  263. SimpleButtonTemplate = RECORD
  264.     ctlTemplate : ControlTemplate;
  265.     titleRef : Ref;
  266.     colorTableRef : Ref;
  267.     keyEquivalent : KeystrokeRec;
  268. END;
  269.  
  270. CheckBoxTemplate = RECORD
  271.     ctlTemplate : ControlTemplate;
  272.     titleRef : Ref;
  273.     initalValue : Integer;
  274.     colorTableRef : Ref;
  275.     keyEquivalent : KeystrokeRec;
  276. END;
  277.  
  278. IconButtonTemplate = RECORD
  279.     ctlTemplate : ControlTemplate;
  280.     iconRef : Ref;
  281.     titleRef : Ref;
  282.     colorTableRef : Ref;
  283.     displayMode : Integer;
  284.     keyEquivalent : KeystrokeRec;
  285. END;
  286.  
  287. LineEditTemplate = RECORD
  288.     ctlTemplate : ControlTemplate;
  289.     maxSize : Integer;
  290.     defaultRef : Ref;
  291. END;
  292.  
  293. ListTemplate = RECORD
  294.     ctlTemplate : ControlTemplate;
  295.     listSize : Integer;
  296.     listView : Integer;
  297.     listType : Integer;
  298.     listStart : Integer;
  299.     listDraw : ProcPtr;
  300.     listMemHeight : Integer;
  301.     listMemSize : Integer;
  302.     listRef : Ref;
  303.     colorTableRef : Ref;
  304. END;
  305.  
  306. PictureTemplate = RECORD
  307.     ctlTemplate : ControlTemplate;
  308.     pictureRef : Ref;
  309. END;
  310.  
  311. PopupTemplate = RECORD
  312.     ctlTemplate : ControlTemplate;
  313.     titleWidth : Integer;
  314.     menuRef : Ref;
  315.     initialValue : Integer;
  316.     colorTableRef : Ref;
  317. END;
  318.  
  319. RadioButtonTemplate = RECORD
  320.     ctlTemplate : ControlTemplate;
  321.     titleRef : Ref;
  322.     initalValue : Integer;
  323.     colorTableRef : Ref;
  324.     keyEquivalent : KeystrokeRec;
  325. END;
  326.  
  327. ScrollBarTemplate = RECORD
  328.     ctlTemplate : ControlTemplate;
  329.     maxSize : Integer;
  330.     viewSize : Integer;
  331.     initalValue : Integer;
  332.     colorTableRef : Ref;
  333. END;
  334.  
  335. SizeBoxTemplate = RECORD
  336.     ctlTemplate : ControlTemplate;
  337.     colorTableRef : Ref;
  338. END;
  339.  
  340. StaticTextTemplate = RECORD
  341.     ctlTemplate : ControlTemplate;
  342.     textRef : Ref;
  343.     textSize : Integer;
  344.     just : Integer;
  345. END;
  346.  
  347. TextEditTemplate = RECORD
  348.     ctlTemplate : ControlTemplate;
  349.     textFlags : Longint;
  350.     indentRect : Rect;
  351.     vertBar : CtlRecHndl;
  352.     vertAmount : Integer;
  353.     horzBar : CtlRecHndl;
  354.     horzAmount : Integer;
  355.     styleRef : Ref;
  356.     textDescriptor : Integer;
  357.     textRef : Ref;
  358.     textLength : Longint;
  359.     maxChars : Longint;
  360.     maxLines : Longint;
  361.     maxCharsPerLine : Integer;
  362.     maxHeight : Integer;
  363.     colorRef : Ref;
  364.     drawMode : Word;
  365.     filterProcPtr : ProcPtr;
  366. END;
  367.  
  368. FUNCTION  CallCtlDefProc ( ctlHandle:CtlRecHndl; ctlMessage:Integer; ctlParam:Longint) : Longint ;
  369. FUNCTION  CMLoadResource ( resourceType:Integer; resourceID:Longint) : Handle ;
  370. PROCEDURE CMReleaseResource ( resourceType:Integer; resourceID:Longint)  ;
  371. PROCEDURE CtlBootInit   ;
  372. PROCEDURE CtlNewRes   ;
  373. PROCEDURE CtlReset   ;
  374. PROCEDURE CtlShutDown   ;
  375. PROCEDURE CtlStartUp ( userID:Integer; dPageAddr:Integer)  ;
  376. FUNCTION  CtlStatus  : Boolean ;
  377. FUNCTION  CtlVersion  : Integer ;
  378. PROCEDURE DisposeControl ( theControlHandle:CtlRecHndl)  ;
  379. PROCEDURE DragControl ( startX:Integer; startY:Integer; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer; theControlHandle:CtlRecHndl)  ;
  380. FUNCTION  DragRect ( actionProcPtr:VoidProcPtr; dragPatternPtr:Pattern; startX:Integer; startY:Integer;VAR dragRectPtr:Rect; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer) : Point ;
  381. PROCEDURE DrawControls ( theWindowPtr:WindowPtr)  ;
  382. PROCEDURE DrawOneCtl ( theControlHandle:CtlRecHndl)  ;
  383. PROCEDURE EraseControl ( theControlHandle:CtlRecHndl)  ;
  384. FUNCTION  FindControl (VAR foundCtl:CtlRecHndl; pointX:Integer; pointY:Integer; theWindowPtr:WindowPtr) : Integer ;
  385. FUNCTION  FindTargetCtl  : CtlRecHndl ;
  386. PROCEDURE FutzCtls   ;
  387. FUNCTION  GetCtlAction ( theControlHandle:CtlRecHndl) : LongProcPtr ;
  388. FUNCTION  GetCtlDPage  : Integer ;
  389. FUNCTION  GetCtlHandleFromID ( ctlWindowPtr:WindowPtr; ctlID:Longint) : CtlRecHndl ;
  390. FUNCTION  GetCtlID ( ctlHandle:CtlRecHndl) : Longint ;
  391. FUNCTION  GetCtlMoreFlags ( ctlHandle:CtlRecHndl) : Integer ;
  392. FUNCTION  GetCtlParamPtr  : Ptr ;
  393. FUNCTION  GetCtlParams ( theControlHandle:CtlRecHndl) : Longint ;
  394. FUNCTION  GetCtlRefCon ( theControlHandle:CtlRecHndl) : Longint ;
  395. FUNCTION  GetCtlTitle ( theControlHandle:CtlRecHndl) : Ptr ;
  396. FUNCTION  GetCtlValue ( theControlHandle:CtlRecHndl) : Integer ;
  397. FUNCTION  GrowSize  : Longint ;
  398. PROCEDURE HideControl ( theControlHandle:CtlRecHndl)  ;
  399. PROCEDURE HiliteControl ( hiliteState:Integer; theControlHandle:CtlRecHndl)  ;
  400. PROCEDURE InvalCtls ( ctlWindowPtr:WindowPtr)  ;
  401. PROCEDURE KillControls ( theWindowPtr:WindowPtr)  ;
  402. FUNCTION  MakeNextCtlTarget  : CtlRecHndl ;
  403. PROCEDURE MakeThisCtlTarget ( ctlToBeTarget:CtlRecHndl)  ;
  404. PROCEDURE MoveControl ( newX:Integer; newY:Integer; theControlHandle:CtlRecHndl)  ;
  405. FUNCTION  NewControl ( theWindowPtr:WindowPtr; boundsRectPtr:Rect; titlePtr:Ptr; flag:Integer; value :Integer; param1:Integer; param2:Integer; defProcPtr:LongProcPtr; refCon:Longint; newColorTablePtr:ColorTablePtr) : CtlRecHndl ;
  406. FUNCTION  NewControl2 ( ownerPtr:WindowPtr; inputDesc:RefDescriptor; inputRef:Ref) : CtlRecHndl ;
  407. PROCEDURE NotifyControls ( notifyMask:Integer; message:Integer; notifyParam:Longint; window:WindowPtr)  ;
  408. PROCEDURE NotifyCtls ( moreFlagsMask:Integer; ctlMessage:Integer; ctlParam:Longint; theWindowPtr:WindowPtr)  ;
  409. FUNCTION  SendEventToCtl ( targetOnlyFlag:Integer; ctlWindowPtr:WindowPtr; eTaskRecPtr:Ptr) : Boolean ;
  410. PROCEDURE SetCtlAction ( newActionPtr:LongProcPtr; theControlHandle:CtlRecHndl)  ;
  411. FUNCTION  SetCtlIcons ( newFontHandle:FontHndl) : FontHndl ;
  412. PROCEDURE SetCtlID ( newID:Longint; ctlHandle:CtlRecHndl)  ;
  413. PROCEDURE SetCtlMoreFlags ( newMoreFlags:Integer; ctlHandle:CtlRecHndl)  ;
  414. PROCEDURE SetCtlParamPtr ( SubArrayPtr:Ptr)  ;
  415. PROCEDURE SetCtlParams ( param2:Integer; param1:Integer; theControlHandle:CtlRecHndl)  ;
  416. PROCEDURE SetCtlRefCon ( newRefCon:Longint; theControlHandle:CtlRecHndl)  ;
  417. PROCEDURE SetCtlTitle ( title:Str255; theControlHandle:CtlRecHndl)  ;
  418. PROCEDURE SetCtlValue ( curValue:Integer; theControlHandle:CtlRecHndl)  ;
  419. PROCEDURE ShowControl ( theControlHandle:CtlRecHndl)  ;
  420. FUNCTION  TestControl ( pointX:Integer; pointY:Integer; theControlHandle:CtlRecHndl) : Integer ;
  421. FUNCTION  TrackControl ( startX:Integer; startY:Integer; actionProcPtr:LongProcPtr; theControlHndl:CtlRecHndl) : Integer ;
  422.  
  423. IMPLEMENTATION
  424.  
  425. END.
  426.